package com.example.controller;

import com.example.pojo.BizProduct;
import com.example.service.BizProductService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
import java.util.Map;

@Slf4j
@Controller
@RequestMapping("/product")
public class ProductController {
    @Autowired
    private BizProductService bizProductService;

    @RequestMapping("/list")
    public String findAll(@RequestParam(defaultValue = "1") Integer pageNum
            , @RequestParam(defaultValue = "3") Integer pageSize, Map map) {
        PageHelper.startPage(pageNum, pageSize);
        List<BizProduct> list = bizProductService.list();
        PageInfo pageInfo = new PageInfo<>(list);
        map.put("pageInfo", pageInfo);
        map.put("pageNum", pageNum);
        return "/";
    }
}
